const Database = require('better-sqlite3');
const db = new Database('app.db');

class User {
    static findByName(name) {
        return db.prepare('SELECT * FROM users WHERE login_name = ?').get(name);
    }
    
    static register(login_name, password) {
        const stmt = db.prepare('INSERT INTO users (login_name, password) VALUES (?, ?)');
        stmt.run(login_name, password);
    }
    
    static getUserById(id) {
        return db.prepare('SELECT * FROM users WHERE id = ?').get(id);
    }
}

module.exports = User;